﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Report_Unity.Unitys
{
    public class IdCardUtils
    {
        public static string GetSex(string idcard)
        {
            string value = idcard.Substring(idcard.Length - 2, 1);
            int z = int.Parse(value);
            if (z % 2 == 0)
                return "女";
            else
                return "男";
        }

        public static string GetBirthday(string idnum)
        {
            string dateStr = string.Empty;
            if (string.IsNullOrEmpty(idnum))
            {
                return dateStr;
            }

            if (idnum.Length == 18)
            {

                dateStr = idnum.Substring(6, 4) + "-" + idnum.Substring(10, 2) + "-" + idnum.Substring(12, 2);

            }
            else if (idnum.Length == 15)
            {
                dateStr = "19" + idnum.Substring(6, 2) + "-" + idnum.Substring(8, 2) + "-" + idnum.Substring(10, 2);
            }

            return dateStr;
        }
    }
}
